# Copyright 2024 Ant Group Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_static_library")
load("//third_party/bazel_rust/cargo:crates.bzl", "all_crate_deps")
load("//third_party/bazel_rust/cargo:rust_cxx_bridge.bzl", "rust_cxx_bridge")
load("@rules_cc//cc:defs.bzl", "cc_library")

package(default_visibility = ["//visibility:public"])

rust_library(
    name = "torus",
    srcs = glob([
        "zq/*.rs",
        "tools/*.rs",
        "lib.rs",
    ]),
    deps = all_crate_deps(package_name = "heu/experimental/tfhe"),
)

rust_static_library(
    name = "torus_static",
    srcs = glob([
        "zq/*.rs",
        "tools/*.rs",
        "lib.rs",
    ]),
    deps = all_crate_deps(package_name = "heu/experimental/tfhe"),
)

rust_binary(
    name = "bench_bootstrap",
    srcs = ["bin/bench_bootstrap.rs"],
    deps = all_crate_deps(package_name = "heu/experimental/tfhe") + [
        ":torus",
    ],
)

cc_library(
    name = "cxx_torus",
    deps = [
        ":ffi.rs",
    ],
)

rust_cxx_bridge(
    name = "ffi.rs",
    src = "zq/ffi.rs",
    deps = [
        ":torus_static",
    ],
)
